#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author   : Uyynot
# @Email    : uyynot@qq.com
# @Time     : 2025/7/18 16:47
# @File     : i.py
# @Project  : demoProject
# @Desc     :
from opensearchpy import OpenSearch


class ES:
    """ES向量数据库管理器"""

    def __init__(self):
        # ES连接配置
        self.host = "localhost"
        self.port = 9200
        self.username = "admin"
        self.password = "StrongPass123!@"


        # 初始化ES客户端
        self.es = OpenSearch(
            [f"http://{self.host}:{self.port}"],
            basic_auth=(self.username, self.password),
            verify_certs=False,
            ssl_show_warn=False
        )
client = ES().es
index_name = 'semantic_search_demo'
mapping = client.indices.get_mapping(index=index_name)
# client.indices.put_mapping(
#     index=index_name,
#     body={"properties": {'id': {"type": 'text'}}}
# )
# mapping1 = client.indices.get_mapping(index=index_name)



new_index_name = "semantic_search_demo_new2"
client.indices.create(index=new_index_name)
client.indices.put_mapping(
    index=new_index_name,
    body={
        "properties": {
            "id": {"type": "keyword"},  # 显式定义 id 为 keyword
            "content": {"type": "keyword"}
        }
    }
)
client.reindex(body={"source": {"index": index_name}, "dest": {"index": new_index_name}})

mapping1 = client.indices.get_mapping(index=new_index_name)

print(333)
print(333)
print(333)
print(333)